// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import Vue from "vue";
// import Vuex from "vuex";
import App from "./App";
import store from "./store/index";
import commit from "./utils/globalCommit";

//声名router
import Router from "vue-router";
import router from "./router";

//使用router
Vue.use(ElementUI);
Vue.use(Router);
// Vue.use(Vuex);

Vue.config.productionTip = false;

// function add1(){
//   var i=0;
//   return function(){
//       //这个函数每次被执行都返回数组arr中 i下标对应的元素
//        return i++ ;
//   }
// }

router.beforeEach((to, from, next) => {
  // 每次路由守卫跳转的时候触发这个钩子
  // console.log('before each invoked')
  next(); // 执行next()路由才会真正的跳转
  commit.title(to.meta.title);
});

/* eslint-disable no-new */
new Vue({
  el: "#app",
  router,
  store,
  render: h => h(App)
});
